package cn.com.taiji.pos.mapper;

import cn.com.taiji.pos.entity.SystemAclUser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 用户信息表 Mapper 接口
 * </p>
 *
 * @author
 * @since 2021-03-01
 */
public interface SystemAclUserMapper extends BaseMapper<SystemAclUser> {

    @Select("SELECT " +
            "COUNT(*) " +
            "FROM " +
            "system_acl_user sac " +
            "LEFT JOIN system_acl_user_role sacr ON sacr.ID = sac.ID " +
            "LEFT JOIN system_acl_role_resource sacrr ON sacr.ROLE_ID = sacrr.ROLE_ID " +
            "WHERE " +
            "sacrr.RESOURCE_ID = #{resourceId} " +
            "AND sac.ID = #{userId}")
    boolean hasAuthority(String resourceId, String userId);

}
